<div class="modal" ng-controller="KisBpmAssignmentPopupCtrl">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true" ng-click="close()">&times;</button>
                <h2 translate>PROPERTY.ASSIGNMENT.TITLE</h2>
            </div>
            <div class="modal-body">
            
            	<div class="row row-no-gutter">
            		<div class="form-group">
            			<label for="assigneeField">{{'PROPERTY.ASSIGNMENT.ASSIGNEE' | translate}}</label>
            			<select id="assigneeField"  class="form-control" ng-model="assignment.assignee" placeholder="{{'PROPERTY.ASSIGNMENT.ASSIGNEE_PLACEHOLDER' | translate}}" >
            				<option>请选择</option>
            			</select>
            			
            		</div>
            	</div>
            	
                <div class="row row-no-gutter">
                    <div class="form-group">
                    	<label for="userField">{{'PROPERTY.ASSIGNMENT.CANDIDATE_USERS' | translate}}</label>
                        <div ng-repeat="candidateUser in assignment.candidateUsers">
            	            <select id="userField" onclick="selectCanUser(this)"  class="form-control"  ng-model="candidateUser.value">
            	            	<option >请选择</option>
            	            </select>    	       
            	            <i class="glyphicon glyphicon-minus clickable-property uplus" ng-click="removeCandidateUserValue($index)"></i>
            	            <i ng-if="$index == (assignment.candidateUsers.length - 1)" class="glyphicon glyphicon-plus clickable-property" ng-click="addCandidateUserValue($index)"></i>
                       		
                        </div>
                   	</div>
            
                    <div class="form-group">
                    	<label for="groupField">{{'PROPERTY.ASSIGNMENT.CANDIDATE_GROUPS' | translate}}</label>
                        <div ng-repeat="candidateGroup in assignment.candidateGroups">
            	          	<select id="groupField" onclick="selectCanGroup(this)"  class="form-control"  ng-model="candidateGroup.value" >
            	          		<option>请选择</option>
            	          	</select>
            	          	<i class="glyphicon glyphicon-minus clickable-property gplus" ng-click="removeCandidateGroupValue($index)"></i>
            	          	<i ng-if="$index == (assignment.candidateGroups.length - 1)" class="glyphicon glyphicon-plus clickable-property" ng-click="addCandidateGroupValue($index)"></i>
                      
                        </div>
                    </div>
                </div>
            
            </div>
            <div class="modal-footer">
                <button ng-click="close()" class="btn btn-primary" translate>ACTION.CANCEL</button>
                <button ng-click="save()" class="btn btn-primary" translate>ACTION.SAVE</button>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
function selectAssUser(){
	jQuery.ajax({
		url:"/TestShiro_3/user/tab",
		type:"get",
		dataType:"json",
		success:function(data){
			var ss= jQuery("#assigneeField").val();
			var num=ss.replace(/[^0-9]/ig,"");
			console.log(num);
			jQuery("#assigneeField option:not(0)").remove();
			jQuery.each(data,function(index,value){
				var option = "";
				if(value.id == num){
					option = "<option value='"+value.id+"' selected='selected'>"+value.username+"</option>";
				}else{
					option = "<option value='"+value.id+"'>"+value.username+"</option>";
				}
				
				jQuery("#assigneeField").append(option);
			})
		}
	})
}
selectAssUser();
function selectCanUser(s){
	if(jQuery(s).children().length>2){
		return;
	}
	jQuery.ajax({
		url:"/TestShiro_3/user/tab",
		type:"get",
		dataType:"json",
		success:function(data){
			var ss=jQuery(s).val();
			var num = ss.replace(/[^0-9]/ig,"");
			console.log(num);
			jQuery(s).children().not(0).remove();
			jQuery.each(data,function(index,value){
				if(value.id == num){
					var option = "<option value='"+value.id+"' selected='selected' >"+value.username+"</option>";
				}else{
					var option = "<option value='"+value.id+"'>"+value.username+"</option>";
				}
				
				jQuery(s).append(option);
			})
		}
	})
}

function selectCanGroup(s){
	if(jQuery(s).children().length>2){
		return;
	}
	jQuery.ajax({
		url:"/TestShiro_3/role/tab",
		type:"get",
		dataType:"json",
		success:function(data){
			var ss=jQuery(s).val();
			var num = ss.replace(/[^0-9]/ig,"");
			console.log(num);
			jQuery(s).children().not(0).remove();
			jQuery.each(data,function(index,value){
				if(value.id==num){
					var option = "<option value='"+value.id+"' selected='selected'>"+value.role+"</option>";
				}else{
					var option = "<option value='"+value.id+"'>"+value.role+"</option>";
				}
				
				jQuery(s).append(option);
			})
		}
	})
}


</script>